<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * 首页
 * @author chenhuan
 *
 */
class Welcome extends MY_Controller {

    public function index() {
        $data = array(
            'account' => 50000,
            'apr' => 18,
            'time_limit' => 1,
            'style' => 0,
            'is_day' => 1,
            'time_limit_day' => 7
        );


        $result = equal_month_interest($data);
        //获取广告条
        $this->load->model('scrollpic_model');

        $vdata = $this->scrollpic_model->get_scrollpic_list();

        //导航条选中
        $vdata['active'] = "index";
        //获取标列表
        $this->load->model('Borrow_model');
        $this->load->model('User_model');
        $this->load->model('Credit_model');
        $param = array(
            'page_size'=>5,
            'page_start'=>0,
            'select'=>1,
            'list'=>1,
        );
        $param['where']['is_mjb'] = 0;
        $vdata['borrow_list'] = $this->Borrow_model->get_borrow_list($param);

        //新手标
        $param['where']['is_mjb'] = 1;
        $vdata['borrow_list_mjb'] = $this->Borrow_model->get_borrow_list($param);

        //推荐
        $vdata['recommend'] = $this->Borrow_model->get_borrow_recommend();

        $vdata['borrow_style'] = $this->Borrow_model->arrays('borrow_style');
        $vdata['borrow_type_img'] = $this->Borrow_model->arrays('borrow_type_img');

        //债权转让列表

        $this->load->model('creditor_model');
        $list = $this->creditor_model->get_list(array('per_page'=>0,'page_size'=>3));

        $vdata['creditorList'] = $list;

        $vdata['guaranteeList'] = $this->Borrow_model->get_guarantee_name_list();

        //理财风云榜
        $month_rank = $this->Borrow_model->index_total(0); //获取月排名
        $vdata['month_rank'] = $month_rank;

        $total_rank = $this->Borrow_model->index_total(5); //获取累计排名
        $vdata['total_rank'] = $total_rank;

        $week_rank = $this->Borrow_model->index_total(4); //获得周排行
        $vdata['week_rank'] = $week_rank;

        //推广风云榜
        $month_popularize = $this->Borrow_model->index_popularize(0); // 月推广
        $vdata['month_popularize'] = $month_popularize;

        $total_popularize = $this->Borrow_model->index_popularize(1); // 累计推广
        $vdata['total_popularize'] = $total_popularize;

        $this->load->model('site_model');
        $this->load->model('article_model');

        //平台优势
        $platsite = $this->site_model->get_site_one(array('url' => 'platedge'));
        $pdata['where']['nid'] = $platsite['id'];
        $plat_list = $this->article_model->get_article_list_index_limit($pdata, 5);
        $vdata['plat_list'] = $plat_list;

        //获取公告
        $gonggaosite = $this->site_model->get_site_one(array('url' => 'gonggao'));
        $cdata['where']['nid'] = $gonggaosite['id'];
        $article22_list = $this->article_model->get_article_list_index_limit($cdata,4);
        $vdata['gonggao_list'] = $article22_list;

        //获取公司咨询
        $companysite = $this->site_model->get_site_one(array('url' => 'company'));
        $cdata['where']['nid'] = $companysite['id'];
        $article_list = $this->article_model->get_article_list_index_limit($cdata,4);
        $vdata['company_list'] = $article_list;

        //友情链接
        $this->load->model('Links_model');
        $vdata['links_list'] = $this->Links_model->get_links_list_index();

        //合作伙伴
        $vdata['cases_list'] = $this->Links_model->get_case_list_index();

        //首页贷款统计
        $this->load->model('Account_model');
        $tongji = $this->Account_model->index_tongji();
        $tongji['interest'] = $tongji['interest'];
        $tongji['account'] = ceil($tongji['account']);
		$tongji['daytrade'] = ceil($tongji['daytrade']);
        $vdata['index_tongji'] = $tongji;

        //print_r($tongji);exit;
        //获取用户资金信息
        if ($this->session->userdata('zjy_user') != null) {
            $user = $this->session->userdata('zjy_user');
            $this->load->model('Account_model');
            $vdata['user_account'] = $this->Account_model->get_account($user['user_id']);
            $tuser_account = $this->User_model->get_by_uid($user['user_id']);
            if ($tuser_account == false) {
                $tuser_account['paypassword'] = "";
            } else {
                $vdata['user_paypassword'] = $tuser_account['paypassword'];
            }
            //每日交易

            //收益总计
            $vdata['income_total'] = $this->Account_model->income_total($user['user_id']);
        }
        //收益总计
		$vdata['income_total_all'] = $this->Account_model->income_total_all();

        //统计注册人数
        $vdata['reg'] = $this->User_model->reg_num();

        //媒体报道
        $meitissite = $this->site_model->get_site_one(array('url' => 'media'));
        $mparms['where']['nid'] = $meitissite['id'];
        $vdata['meiti_list'] = $this->article_model->get_article_index_report_limit($mparms);

        //最新报道
        $newssite = $this->site_model->get_site_one(array('url' => 'news'));
        $nparms['where']['nid'] = $newssite['id'];
        $vdata['news_list'] = $this->article_model->get_article_index_report_limit($nparms);

        //财富报道
        $richessite = $this->site_model->get_site_one(array('url' => 'rich'));
        $rparms['where']['nid'] = $richessite['id'];
        $vdata['rich_list'] = $this->article_model->get_article_index_report_limit($rparms);


        $invite = $this->input->get('invite');
        if ($invite) {
            setcookie("inviteRequest", $invite, time() + 3600);
        }

        $vdata['tab'] = 'welcome';
        $vdata['title'] = CON_PLATFORMNAME;
        $vdata['userInfo'] = $this->session->userdata('zjy_user');
		
        $this->load->view('index', $vdata);
    }

}
